//
// Created by alexa on 5/11/2024.
//
#include "PreviewMenu.h"
#include "../../keydown-handler/KeydownHandler.h"
#include <iostream>

using namespace std;

PreviewMenu::PreviewMenu(i18n::Translator *t, UserInterface *ui) : Menu(t, ui) {}

void PreviewMenu::printMenu() {
    clearScreen();
    cout << (*t)("university", "preview") << endl;
    cout << (*t)("faculty", "preview") << endl;
    cout << (*t)("department", "preview") << endl;

    cout << endl << endl;

    cout << (*t)("proj-title1", "preview") << endl;
    cout << (*t)("proj-title2", "preview") << endl;
    cout << (*t)("proj-title3", "preview") << endl;

    cout << endl << endl;

    cout << (*t)("supervisor1", "preview") << endl;
    cout << (*t)("supervisor2", "preview") << endl;
    cout << (*t)("supervisor3", "preview") << endl;

    cout << endl;

    cout << (*t)("executor1", "preview") << endl;
    cout << (*t)("executor2", "preview") << endl;
    cout << (*t)("executor3", "preview") << endl;

    cout << endl << endl;

    cout << (*t)("place-date", "preview") << endl;

    cout << endl;
}

void PreviewMenu::displayMenu() {
    printMenu();
    cout << (*t)("change-lang", "general") << endl;
    cout << (*t)("start-keybind", "preview") << endl;
    cout << (*t)("about-author", "preview") << endl;
    cout << (*t)("about-program", "preview") << endl;
    cout << (*t)("operator-manual", "preview") << endl;
    cout << (*t)("exit", "preview") << endl;

    return keydownHandle(ui->getPressedKey, {
            {Keys::TAB,   [this]() {
                ui->toggleLocale();
                return displayMenu();
            }},
            {Keys::ENTER, [this]() {
                ui->setCurrentPage(Pages::MAIN_MENU);
            }},
            {Keys::KEY_P, [this]() {
                ui->setCurrentPage(Pages::ABOUT_PROGRAM_MENU);
            }},
            {Keys::KEY_O, [this]() {
                ui->setCurrentPage(Pages::OPERATOR_MANUAL_MENU);
            }},
            {Keys::KEY_A, [this]() {
                ui->setCurrentPage(Pages::ABOUT_AUTHOR_MENU);
            }},
            {Keys::ESC, [this]() {
                ui->setCurrentPage(Pages::EXIT);
            }}
    });
}
